﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MessageWorkflow.Handler;
using SimpleWpfExample.ViewModel;

namespace SimpleWpfExample.MessageHandler
{
    class AuthenticateNewUser : SingleWorkflowHandler<Message.RequestAuthenticatedUser>
    {
        protected override void OnCurrentMessageChanged()
        {
            base.OnCurrentMessageChanged();

            UserViewModel userViewModel = new UserViewModel();
            AuthenticateWindow window = new AuthenticateWindow()
            {
                DataContext = userViewModel
            };

            window.Closed += new EventHandler(OnWindowClosed);

            window.Show();
        }

        void OnWindowClosed(object sender, EventArgs e)
        {
            AuthenticateWindow window = (AuthenticateWindow)sender;

            window.Closed -= OnWindowClosed;
        }
    }
}
